using System;
using System.Collections.Generic;
using System.Text;

using System.Data;
using System.Data.Common;

using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Caching;

using Husb.Data;
using Husb.DataUtil;

using CentralOffice.Enterprise.Data;

using NoticeTable = CentralOffice.Enterprise.Data.EnterpriseNoticeDataSet.NoticesDataTable;
using NoticeRow = CentralOffice.Enterprise.Data.EnterpriseNoticeDataSet.NoticesRow;

namespace CentralOffice.Enterprise.DataAccess
{
    public class EnterpriseNoticeAdapter : DataAccessAdapter<EnterpriseNoticeDataSet, NoticeTable, NoticeRow>
    {        
        public EnterpriseNoticeAdapter()
        {
            //this.TableName = "Enterprise.Notices";
            this.TableName = "Notices";

            GetAllStoredProc = "Enterprise.Notices_SelectNoticesAll";
            InsertStoredProc = "Enterprise.Notices_InsertNotice";
            UpdateStoredProc = "Enterprise.Notices_UpdateNotice";
            DeleteStoredProc = "Enterprise.Notices_DeleteNotice";

            GetByIdStoredProc = "Enterprise.Notices_SelectNotice";
            GetByNameStoredProc = "";
            GetPagedStoredProc = "Enterprise.Notices_SelectNoticesPaged";
            GetRowCountStoredProc = "Enterprise.Notices_SelectNoticesRowCount";

            FindStoredProc = "Enterprise.Notices_SelectNoticesDynamic";
        }
        protected override void PopulateInsertParameters(Database db, DbCommand cmd)
        {
            db.AddInParameter(cmd, "Id", DbType.Guid, "Id", DataRowVersion.Current);

            db.AddInParameter(cmd, "Name", DbType.AnsiString, "Name", DataRowVersion.Current);
            db.AddInParameter(cmd, "NoticeNumber", DbType.AnsiString, "NoticeNumber", DataRowVersion.Current);
            db.AddInParameter(cmd, "QueryNumber", DbType.AnsiString, "QueryNumber", DataRowVersion.Current);
            db.AddInParameter(cmd, "Significant", DbType.AnsiString, "Significant", DataRowVersion.Current);
            db.AddInParameter(cmd, "Profile", DbType.AnsiString, "Profile", DataRowVersion.Current);
            db.AddInParameter(cmd, "IsTop", DbType.Boolean, "IsTop", DataRowVersion.Current);
            db.AddInParameter(cmd, "Accepter", DbType.AnsiString, "Accepter", DataRowVersion.Current);
            db.AddInParameter(cmd, "ReceiverType", DbType.Int32, "ReceiverType", DataRowVersion.Current);
            db.AddInParameter(cmd, "EnterpriseCategoryId", DbType.Guid, "EnterpriseCategoryId", DataRowVersion.Current);
            db.AddInParameter(cmd, "PublishDate", DbType.DateTime, "PublishDate", DataRowVersion.Current);
            db.AddInParameter(cmd, "Status", DbType.AnsiString, "Status", DataRowVersion.Current);
            db.AddInParameter(cmd, "ContentText", DbType.String, "ContentText", DataRowVersion.Current);
            db.AddInParameter(cmd, "Attachments", DbType.String, "Attachments", DataRowVersion.Current);

            db.AddInParameter(cmd, "IsDeleted", DbType.Boolean, "IsDeleted", DataRowVersion.Current);
            db.AddInParameter(cmd, "IsActive", DbType.Boolean, "IsActive", DataRowVersion.Current);
            db.AddInParameter(cmd, "CreatedTime", DbType.DateTime, "CreatedTime", DataRowVersion.Current);
            db.AddInParameter(cmd, "CreatedBy", DbType.Guid, "CreatedBy", DataRowVersion.Current);
            db.AddInParameter(cmd, "ModifiedTime", DbType.DateTime, "ModifiedTime", DataRowVersion.Current);
            db.AddInParameter(cmd, "LastModifiedBy", DbType.Guid, "LastModifiedBy", DataRowVersion.Current);
            db.AddInParameter(cmd, "Version", DbType.Int32, "Version", DataRowVersion.Current);
            db.AddInParameter(cmd, "Description", DbType.String, "Description", DataRowVersion.Current);
        }

        //public override EnterpriseNoticeDataSet.NoticesDataTable GetPaged(int startRowIndex, int maximumRows, string sortExpression, string whereClause, string orderBy, bool isStoredProc, bool enableCache)
        //{
        //    whereClause = DataAccessUtil.AppendDeletedWhereClause(whereClause);
        //    return base.GetPaged(startRowIndex, maximumRows, sortExpression, whereClause, orderBy, isStoredProc, enableCache);
        //}

        //public override int GetCount(string whereClause, bool enableCache)
        //{
        //    whereClause = DataAccessUtil.AppendDeletedWhereClause(whereClause);
        //    return base.GetCount(whereClause, enableCache);
        //}
    }
}
